module LoomsHelper
  def containers_in_inventory(fabric,code)
    @ct = "nothing" + code
    # put this in helper
    code = code.to_i
    cont_state = ContainerState.find_by_code(0)
    case code
    when 0
      containers = Container.find(:all, :conditions => ["container_state_id = ? and yarn_id = ?", cont_state, fabric.weft_yarn.id])
      @ct = "warp"
    when 1
      containers = Container.find(:all, :conditions => ["container_state_id = ? and yarn_id = ?", cont_state, fabric.warp_yarn.id])
      @ct = "weft"
    when 2
      containers = Container.find(:all, :conditions => ["container_state_id = ? and yarn_id = ?", cont_state, fabric.creel_yarn.id])
      @ct = "creel"
    else
      containers = Container.find(:all, :conditions => ["container_state_id = ?", cont_state])
      @ct = "all"
    end
    containers = containers.collect { |ct| [ct.code, ct.id] }
    containers
	end
	  
	def all_fabrics
	  @fabrics = Fabric.find(:all)
	  @fabrics = @fabrics.collect {|fb| [fb.style_code, fb.id]}
	  @fabrics
  end
end
